/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package org.teacup.eightdays.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import org.teacup.eightdays.model.*;
import org.teacup.eightdays.dao.*;
import org.teacup.eightdays.service.*;
import org.teacup.eightdays.vo.query.*;

/**
 * @author Abner email:521yexu2008(a)163.com
 * @version 1.0
 * @since 1.0
 */

@Entity
@Table(name = "taste")
public class Taste extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "Taste";
	public static final String ALIAS_TASTE_ID = "ID";
	public static final String ALIAS_PRODUCT_ID = "产品ID";
	public static final String ALIAS_NAME = "名称";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * ID       db_column: taste_id 
     */ 	
	
	private java.lang.Long tasteId;
    /**
     * 产品ID       db_column: product_id 
     */ 	
	
	private java.lang.Long productId;
    /**
     * 名称       db_column: name 
     */ 	
	@NotBlank @Length(max=100)
	private java.lang.String name;
	//columns END


	public Taste(){
	}

	public Taste(
		java.lang.Long tasteId
	){
		this.tasteId = tasteId;
	}

	

	public void setTasteId(java.lang.Long value) {
		this.tasteId = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "taste_id", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getTasteId() {
		return this.tasteId;
	}
	
	@Column(name = "product_id", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getProductId() {
		return this.productId;
	}
	
	public void setProductId(java.lang.Long value) {
		this.productId = value;
	}
	
	@Column(name = "name", unique = false, nullable = false, insertable = true, updatable = true, length = 100)
	public java.lang.String getName() {
		return this.name;
	}
	
	public void setName(java.lang.String value) {
		this.name = value;
	}
	
	
	private Product product;
	public void setProduct(Product product){
		this.product = product;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "product_id",nullable = false, insertable = false, updatable = false) 
	})
	public Product getProduct() {
		return product;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("TasteId",getTasteId())
			.append("ProductId",getProductId())
			.append("Name",getName())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getTasteId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof Taste == false) return false;
		if(this == obj) return true;
		Taste other = (Taste)obj;
		return new EqualsBuilder()
			.append(getTasteId(),other.getTasteId())
			.isEquals();
	}
}

